home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / BORUSR2.ZIP;1 / BORREP.PRG < prev    next >
Encoding:
Text File  |  1992-06-29  |  34.7 KB  |  1,070 lines

  1. *-------------------------------------------------------------------------------
  2. *-- Program.....: BORREP.PRG
  3. *-- Programmer..: Ken Mayer
  4. *-- Date........: 06/16/1992
  5. *-- Notes.......: This program prints out a list of all the data in the 
  6. *--               BOR-BBS database.
  7. *--               Note that this program takes time for each individual record,
  8. *--               due to some intensive IIF functions, as well is simple IF
  9. *--               and CASE commands. It makes the report VERY flexible, but it
  10. *--               does make it a bit slow ... have some patience ...
  11. *-- Written for.: dBASE IV, 1.1
  12. *-- Rev. History: Minor changes here and there to cut back on wasted paper ...
  13. *--               02/15/1992 -- Changes made to incorporate some of the 
  14. *--                configuration stuff that Bowen wrote (and I aggregiously
  15. *--                borrowed and modified and ...). This should allow the user
  16. *--                to display the data on the screen, to a file, or to a
  17. *--                printer, and if a printer, to choose one of two printers.
  18. *--               03/11/1992 -- Beginning of even more complexities ...
  19. *--                I am going to give the user the option to list the data
  20. *--                sorted by Lastname or BORBBSID. I will then allow them to
  21. *--                use a filter if they wish ... options so far include:
  22. *--                  State = userinputstate
  23. *--                  Those with a BBS ...
  24. *--                  Those with a fax ...
  25. *--               03/27/1992 -- Minor ... use of NETWORK() to handle exclusive
  26. *--                 use of dbf if necessary, and handled getting out of the
  27. *--                 printstatus() loop by pressing <Esc> key ...
  28. *--               05/31/1992 -- (hopeful) fixes based on Beta Tester input,
  29. *--                 includes <Esc> a bit smoother, and so on ...
  30. *--               06/04/1992 -- more changes based on some stuff from Joey
  31. *--                 and Keith. Should be pretty close to clean now ...
  32. *--               06/15/1992 -- added routines to handle printing the
  33. *--                 new memo field "BIO".
  34. *--               06/29/1992 -- Added Joey's new PROGBAR procedure in place
  35. *--                 of the MONITOR routine. Rather spiffy, if you ask me ...
  36. *--------------------------------------------------------------------------
  37. *-- Please note the logic can get a bit odd, although I've tried to make this
  38. *-- as clear as possible. It may seem like mud ... >sigh<. The real problem is
  39. *-- that the routine started out simple, and I kept adding to it, which is the
  40. *-- usual problem with difficult to follow code. I have tried, consequently,
  41. *-- to add even more comments than usual to my code, in an attempt to make it
  42. *-- as easy to follow as possible ... KJM.
  43. *-------------------------------------------------------------------------------
  44.  
  45. *-- setup
  46. @24,0 clear                && clear out message at bottom of screen from menu
  47. *-- If network, use file in exclusive mode ...
  48. if network()
  49.     use atusers excl        && open data exclusive on network
  50. else
  51.     use atusers             && normal otherwise ...
  52. endif
  53. set escape on              && allow user to press <Esc> and note it ...
  54. lEsc = .f.                 && did user press <Esc>?
  55. on escape lEsc = .t.       && if so, turn this on ...
  56. cFile = " "                && declare it here, so it's available ...
  57.  
  58. *-- screen handling ...
  59. save screen to sRep
  60. cRepColor = set("ATTRIBUTE")
  61. clear
  62. ?scrnhead("&cstand2","Print BOR-BBS Data")
  63.  
  64. *-------------------------------------------------------------------------------
  65. *-- Ask if they want the data sorted by last name or Borland BBS Id ...
  66. *-------------------------------------------------------------------------------
  67.  
  68. *-- now find out about sorting, using Keith's routine VPick()
  69. cSortHow = VPick(8,30,"~Lastname~Borland BBS ID","Sort the List by:",;
  70.                     "Choose one, or <Esc> to quit",.t.,"&cStand2,&cStand,&cStand2")
  71.  
  72. if lastkey() = 27                && User pressed <Esc>
  73.      lEsc = .t.
  74. endif
  75.  
  76. *-- Exit ...
  77. if lEsc
  78.     *-- reset the environment ...
  79.     restore screen from sRep
  80.     release screen sRep
  81.     do ReColor with cRepColor
  82.     RETURN
  83. endif
  84.  
  85. *-- didn't choose to exit, set the MDX tag ...
  86. if cSortHow = "L"
  87.     set order to last_name
  88. else
  89.     set order to borbbs_id
  90. endif
  91.  
  92. *-------------------------------------------------------------------------------
  93. *-- deal with a filter ... (or not)
  94. *-------------------------------------------------------------------------------
  95. cFilter = " "        && initialize this here, since we will need to have
  96.                      && the memvar available ...
  97. @5,0 clear
  98.  
  99. *-- first ask if they want to use one at all ...
  100. if yesno(.f.,"Do you want a filter?","You can extract specific data",;
  101.              "this way ...","&cl_wind1")
  102.  
  103.     *-- if yes, find out what filter they want ... note that a blank response
  104.     *-- will avoid using a filter after all ...
  105.     cType = VPick(8,30,"~State~BBS (those with)~Fax (those with)",;
  106.                  "Filter by:","Choose one or <Esc> for none",.t.,;
  107.                      "&cStand2,&cStand,&cStand2")
  108.     
  109.     if IsBlank(cType)   && clear out message ...
  110.         if lEsc          && if user pressed <Esc> in this picklist, they may
  111.                          &&   want to continue anyway
  112.             lEsc = .f.    && so set lEsc to false.
  113.         endif
  114.     endif
  115.     
  116.     do case
  117.         case cType = "S"
  118.             *-- deal with getting "state" -- we're looping so that the user
  119.             *-- can enter a valid state code if they got the wrong one ...
  120.             *-- or if no records match ...
  121.             do while .t.  && loop until a valid state, or no filter ...
  122.                 cState = "  "
  123.                 @12,10 say "Enter state code: " get cState picture "!!";
  124.                     valid required state(cState);
  125.                     error chr(7)+"Enter a valid state code"
  126.                 read
  127.                 
  128.                 go top
  129.                 *-- find out if there's anything to print
  130.                 count to nCount for (hstate = cState .or. bstate = cState)
  131.                 
  132.                 *-- if not (nCount = 0), error message, ask if they want to 
  133.                 *-- try again
  134.                 if nCount = 0
  135.                     @13,10 say "** There are no records that match that code **"
  136.                     cYN = " "
  137.                     @14,10 say "Do you wish to try again? " get cYN picture "!";
  138.                         valid required cYN $ "YN";
  139.                         error chr(7)+"Enter 'Y' or 'N'"
  140.                     read
  141.                     if cYN = "Y"
  142.                         loop
  143.                     else
  144.                         set filter to
  145.                         exit
  146.                     endif  && cYN ...
  147.                 *-- if here, we have more than one state ...
  148.                 else  
  149.                     *-- deal with the fact that there are two fields that have
  150.                     *-- state values in 'em ... Home State (HState) and Business
  151.                     *-- state (BState)    
  152.                     set filter to hstate = cState .or. bstate = cState
  153.                     cFilter = "hstate = cState .or. bState = cState"
  154.                     go top && since we moved the pointer ...
  155.                     exit   && out of loop ...
  156.                 endif     && nCount = 0
  157.             enddo
  158.             @5,0 clear
  159.             
  160.         *-- Those users with BBS's
  161.         case cType = "B"
  162.             set filter to .not. isblank(bbsphone)
  163.             cFilter = ".not. isblank(bbsphone)"
  164.             
  165.         *-- Those users with Fax Numbers
  166.         case cType = "F"
  167.             set filter to .not. isblank(fax)
  168.             cFilter = ".not. isblank(fax)"
  169.             
  170.     endcase
  171.     *-- no otherwise ... if user decides NOT to use a filter,
  172.     *-- do NOTHING ...
  173. endif
  174.  
  175. *-------------------------------------------------------------------------------
  176. *-- save current printer settings, so we can restore them later ...
  177. *-------------------------------------------------------------------------------
  178. cPDriver = _pDriver
  179. cPEject  = _pEject
  180. nPLength = _pLength
  181. lPWait   = _pWait
  182. lPQuality= _pQuality
  183. nPageLen = 65                    && default page length for file/paper report
  184. lToFile   = .f.
  185. lToScreen = .f.
  186. nMemoWidth = set("MEMOWIDTH")    && save setting
  187. set memowidth to 70              && might as well take advantage of
  188.                                  && the width of the page ...
  189.  
  190. *-------------------------------------------------------------------------------
  191. *-- find out where the user wants to print this ...
  192. *-------------------------------------------------------------------------------
  193. if .not. lEsc
  194.     on error do err_routine       && routine handles pquality problems ... I hope
  195.     do prntchoose                 && new routine below, based on
  196.                                  &&   Bowen Moursund's PRNTDEMO program
  197. endif
  198.  
  199. *===============================================================================
  200. *-- PROGRAMMER NOTE:
  201. *--    If you are using this on a network, please 
  202. *--    comment out or delete the following few
  203. *--    program lines, as PRINTSTATUS() does NOT
  204. *--    function on a network properly and may give
  205. *--    an error where none exists ...
  206. *===============================================================================
  207. on error
  208. do while .not. printstatus() .and. .not. lToScreen .and. .not. lToFile ;
  209.     .and. .not. lEsc
  210.     do printerr
  211. enddo
  212.  
  213. *-------------------------------------------------------------------------------
  214. *-- Printer message -- GET THE PRINTER READY, DUMMY!
  215. *-------------------------------------------------------------------------------
  216. if .not. lToScreen .and. .not. lToFile .and. .not. lEsc
  217.  
  218.     do center with 10,80,"&cStand2","Make sure the printer is ready,"
  219.     do center with 11,80,"&cStand2","OnLine, Turned On, has Paper."
  220.     do center with 12,80,"&cstand2","Press any key when ready to start ..."
  221.     x=inkey(0)
  222.     @10,0 clear to 12,79
  223.     if x = 27
  224.         lEsc = .t.
  225.     endif  && x = 27
  226.  
  227. endif  && .not. lToScreen, etc ...
  228.  
  229. *-------------------------------------------------------------------------------
  230. *-- If sending output to a file, let user know where it's being sent to ...
  231. *-------------------------------------------------------------------------------
  232. if lToFile .and. .not. lEsc  && to file, and user didn't press 
  233.     do center with 12,80,"&cStand2","Sending output to "+trim(cFile)
  234. endif
  235.  
  236. *-------------------------------------------------------------------------------
  237. *-- display window on screen for user with message ...
  238. *--    Unless user is sending output to screen ...
  239. *-------------------------------------------------------------------------------
  240. if .not. lToScreen .and. .not. lEsc && not to screen and user didn't press <Esc>
  241.     do center with 13,80,"&cStand2","Patience ... each record takes time"
  242.     cMonColor = set("ATTRIBUTE")
  243.     if isblank(cFilter)
  244.         nRecords = RECCOUNT()
  245.     else
  246.         count to nRecords for &cFilter
  247.     endif
  248.     go top
  249.     *-- turn off the screen, turn ON the printer (or file if using a file)  ...
  250.     set cursor off
  251.     set console off
  252.     set device to print 
  253.     set print on
  254. endif
  255.  
  256. *-------------------------------------------------------------------------------
  257. *-- If user IS sending output to screen, then activate window, and so on ...
  258. *-------------------------------------------------------------------------------
  259. if lToScreen .and. .not. lEsc && to screen and user did not press <Esc>
  260.     activate window wrep2scr
  261. endif
  262.  
  263. *-------------------------------------------------------------------------------
  264. *--                                And AWAAAAAAY we GO!
  265. *-------------------------------------------------------------------------------
  266. *-- set counters/other items
  267. nRecNo = 0
  268. nPage = 0
  269. nLine = 0
  270. lHeading = .t.
  271. if .not. isblank(cFilter)
  272.     cFilter = ".and. "+cFilter
  273. endif
  274. *-------------------------------------------------------------------------------
  275. * start processing
  276. *-------------------------------------------------------------------------------
  277. go top
  278.     *-- error routine is now designed to handle printer offline, turned off,
  279.     *-- and not connected ... I hope.
  280.     if .not. lToScreen .and. .not. lToFile
  281.         on error do err_routine
  282.     endif
  283.     
  284.     *-- check for: End of File, use filter if it exists, and check to see
  285.     *-- if user pressed the ESCape key in the PRINTSTATUS loop ...
  286.     do while .not. eof() &cFilter .and. .not. lEsc
  287.         
  288.         *-- if not sending output to the screen, update the MONITOR window
  289.         if .not. lToScreen
  290.             set device to screen
  291.             set console on
  292.             do progbar with nRecords,"&cl_wind1","&cStand2","&cStand3",;
  293.                 ". . . Printing . . .",70
  294.             set device to print
  295.             set console off
  296.         endif
  297.         
  298.         *-- check how many lines we've printed
  299.         if nLine => nPageLen
  300.             lHeading = .t.
  301.         endif
  302.         
  303.         *-- check to see if enough room for next record ...
  304.         if .not. lHeading 
  305.             do LineCount  && procedure below to count lines of next record ...
  306.         endif
  307.         
  308.         *-- check for heading ...
  309.         if lHeading
  310.             do heading
  311.         endif && lHeading
  312.         
  313.         *--------------------------------------------------------------------
  314.         *-- Here is where we start printing the detail lines
  315.         *--------------------------------------------------------------------
  316.         ?? "Borland BBS ID: "+borbbs_id at 5 style "B"
  317.         *-- print Honorific first mi last
  318.         *-- i.e., Mr. Kenneth J. Mayer (or, if no honorific, Kenneth J. Mayer,
  319.         *-- or, if no MI,  Kenneth Mayer ...)
  320.         if .not. IsBlank(honorific)
  321.             ?? trim(honorific) at 32
  322.         endif
  323.         ?? trim(first_name)+" "+iif(.not. IsBlank(mi),mi+". ","")+;
  324.             last_name  at 32+len(trim(honorific))+;
  325.                 iif(.not. IsBlank(honorific),1,0)
  326.         ?
  327.         nLine = nLine + 1
  328.         
  329.         *-----------------------------------------------------
  330.         *-- home address/phone first (before business/work)...
  331.         *-----------------------------------------------------
  332.         *-- First, look to see if there's anything to print in HOME info ...
  333.         if .not. IsBlank(haddress1) .or. .not. IsBlank(hcity) .and. ;
  334.             .not. IsBlank(hPhone)
  335.             ?? "Home:" style "U" at 7
  336.             if .not. IsBlank(hphone) 
  337.                 ?? hphone picture "@R (999) 999-9999" at 17
  338.             endif
  339.             ?
  340.             nLine = nLine + 1
  341.         endif
  342.         
  343.         *-- Print home address
  344.         if .not. IsBlank(hAddress1)
  345.             ?? trim(hAddress1) at 9
  346.             *-- add this to end of first address line ...
  347.             if .not. IsBlank(haddress2)
  348.                 ?? ", "+haddress2
  349.             endif  && .not. IsBlank(haddress2)
  350.             ?
  351.             nLine = nLine + 1    
  352.         endif  && .not. IsBlank(haddress1)
  353.         
  354.         *-- Print city, state, zip ...
  355.         if .not. IsBlank(hcity)
  356.             *-- for zip, if > 6 it's extended postal code, otherwise,
  357.             *-- don't print the '-' that's in the picture code ...
  358.             ?? trim(hCity)+", "+hstate+"  "+;
  359.                 iif(len(trim(hzip))>6,hzip,left(hZip,5)) at 9
  360.             ?
  361.             nLine = nLine + 1
  362.         endif  && .not. IsBlank(hCity)
  363.         
  364.         *----------------------------------------------------------------
  365.         *-- Business info ... print ANY business info if it exists ...
  366.         *----------------------------------------------------------------
  367.         if .not. IsBlank(baddress1) .or. .not. IsBlank(company) .or. ;
  368.             .not. IsBlank(title) .or. .not. IsBlank(bcity) .or. ;
  369.             .not. IsBlank(bPhone)
  370.             ?? "Business:" style "U" at 7
  371.             if .not. IsBlank(bPhone)
  372.                 ?? bPhone picture "@R (999) 999-9999" at 17
  373.             endif
  374.             ?
  375.             nLine = nLine + 1
  376.         endif
  377.         
  378.         *-- see if company name exists ...
  379.         if .not. IsBlank(company)
  380.             ?? trim(company) at 9
  381.             if .not. IsBlank(title)
  382.                 ?? ",  "+title
  383.             endif  && .not. IsBlank(title)
  384.             ?
  385.             nline = nline + 1
  386.         else
  387.             if .not. IsBlank(title)
  388.                 ?? title at 9
  389.                 ?
  390.                 nLine = nLine + 1
  391.             endif  && .not. IsBlank(title)
  392.         endif  && .not. IsBlank(company)
  393.         
  394.         *-- Company/Business Address
  395.         if .not. IsBlank(baddress1)
  396.             ?? trim(bAddress1) at 9
  397.             if .not. IsBlank(baddress2)
  398.                 ?? ",  "+baddress2
  399.             endif  && .not. IsBlank(bAddress2)
  400.             ?
  401.             nLine = nLine + 1
  402.         else
  403.             if .not. IsBlank(baddress2)
  404.                 ?? baddress2 at 9
  405.                 ?
  406.                 nLine = nLine + 1
  407.             endif  && .not. IsBlank(baddress2)
  408.         endif  && .not. IsBlank(bAddress1)
  409.         
  410.         *-- Company/Business City, state zip
  411.         if .not. IsBlank(bcity)
  412.             ?? trim(bcity)+", "+bstate+"  "+;
  413.                 iif(len(trim(bzip))>6,bzip,left(bzip,5)) at 9
  414.             ?
  415.             nLine = nLine + 1
  416.         endif
  417.         
  418.         *-------------------
  419.         *-- Other info ...
  420.         *-------------------
  421.         do case
  422.             case .not. IsBlank(fax) .and. .not. IsBlank(bbsphone) && both
  423.                 ?? "Fax:" style "U" at 7,;
  424.                     fax picture "@R (999) 999-9999" at 12,;
  425.                     "BBS:" style "U" at 28,;
  426.                     bbsphone picture "@R (999) 999-9999" at 33
  427.                 ?
  428.                 nLine = nLine + 1
  429.             case .not. IsBlank(fax) .and. IsBlank(bbsphone)  && fax only
  430.                 ?? "Fax:" style "U" at 7,;
  431.                     fax picture "@R (999) 999-9999" at 12
  432.                 ?
  433.                 nLine = nLine + 1
  434.             case IsBlank(fax) .and. .not. IsBlank(bbsphone)  && bbs only
  435.                 ?? "BBS:" style "U" at 7,;
  436.                     bbsphone picture "@R (999) 999-9999" at 12
  437.                 ?
  438.                 nLine = nLine + 1
  439.         endcase
  440.         
  441.         *-- other electronic mail sources ...
  442.         if .not. IsBlank(compuserve) .or. .not. IsBlank(mci_mail) .or.;    
  443.             .not. IsBlank(genie) .or. .not. IsBlank(fido) .or.;
  444.             .not. IsBlank(internet) .or. .not. IsBlank(source) .or.;
  445.             .not. IsBlank(prodigy) .or. .not. IsBlank(delphi) .or.;
  446.             .not. IsBlank(am_online)
  447.             ?? "EMAIL Addresses:" style "U" at 7
  448.             ?
  449.         endif
  450.         do case
  451.             case .not. IsBlank(compuserve) .and. .not. IsBlank(mci_mail)
  452.                 ?? "CIS: "+compuserve at 9,;
  453.                     "MCI: "+mci_mail at 27
  454.                 ?
  455.                 nLine = nLine + 1
  456.             case .not. IsBlank(compuserve) .and. IsBlank(mci_mail)
  457.                 ?? "CIS: "+compuserve at 9
  458.                 ?
  459.                 nLine = nLine + 1
  460.             case IsBlank(compuserve) .and. .not. IsBlank(mci_mail)
  461.                 ?? "MCI: "+mci_mail at 9
  462.                 ?
  463.                 nLine = nLine + 1
  464.         endcase
  465.         
  466.         do case
  467.             case .not. IsBlank(genie) .and. .not. IsBlank(fido)
  468.                 ?? "GEnie: "+genie at 9,;
  469.                     "FIDO: "+fido at 42
  470.                 ?
  471.                 nLine = nLine + 1
  472.             case .not. IsBlank(genie) .and. IsBlank(fido)
  473.                 ?? "GEnie: "+genie at 9
  474.                 ?
  475.                 nLine = nLine + 1
  476.             case IsBlank(genie) .and. .not. IsBlank(fido)
  477.                 ?? "FIDO: "+fido at 9
  478.                 ?
  479.                 nLine = nLine + 1
  480.         endcase
  481.         
  482.         if .not. IsBlank(internet)
  483.             ?? "Internet: "+internet at 9
  484.             ?
  485.             nLine = nLine + 1
  486.         endif
  487.         
  488.         if .not. IsBlank(prodigy)
  489.             ?? "Prodigy: "+prodigy at 9
  490.             ?
  491.             nLine = nLine + 1
  492.         endif
  493.         
  494.         if .not. IsBlank(Delphi)
  495.             ?? "Delphi: "+delphi at 9
  496.             ?
  497.             nLine = nLine + 1
  498.         endif
  499.         
  500.         if .not. IsBlank(am_online)
  501.             ?? "America Online: " at 9
  502.             ?
  503.             ?? am_online at 11
  504.             ?
  505.             nLine = nLine + 2
  506.         endif
  507.         
  508.         if .not. IsBlank(source)
  509.             ?? "Source: "+source at 9
  510.             ?
  511.             nLine = nLine + 1
  512.         endif
  513.         
  514.         *--------------------------------------------------------------------
  515.         *-- This section deals with the MEMO field ...
  516.         *--------------------------------------------------------------------
  517.         if memlines(bio) > 0
  518.         
  519.             *-- Don't print on screen, but if there's something
  520.             *-- here, we want the user to know it ...
  521.             if lToScreen 
  522.                 ?? "** DATA IN USER BIO FIELD **" at 7 style "B"
  523.                 ?
  524.                 nLine = nLine + 1
  525.             
  526.             else
  527.             
  528.                 *-- print field info ...
  529.                 ?? "User BIO: " at 7 style "B"
  530.                 ?
  531.                 nLine = nLine + 1
  532.                 
  533.                 nMemCount = 0                  && init line counter ...
  534.                 nMemLines = memlines(bio)      && store number of lines in memo
  535.                 
  536.                 *-- if the memo is longer than the bottom of the page,
  537.                 *-- rather than moving the whole record to the next page,
  538.                 *-- we're going to deal with a special heading routine.
  539.                 if nLine => 57 .and. nMemLines => 5
  540.                     do heading2
  541.                 endif  && nLines => 55 ...
  542.                 
  543.                 *-- now we're going to loop until we've printed each line of
  544.                 *-- the memo.
  545.                 do while nMemCount < nMemLines  && one line at a time ...
  546.                 
  547.                     *-- check for memo printing toward bottom of page,
  548.                     *-- and if there's more than one line left in memo
  549.                     *-- to print ...
  550.                     if nLine => 59 .and. (nMemLines-nMemCount) => 1
  551.                           && time to go to a new page?
  552.                         do heading2
  553.                     endif
  554.                     
  555.                     *-- print the current line of the memo
  556.                     nMemCount = nMemCount + 1
  557.                     ?? mLine(bio,nMemCount) at 7
  558.                     ?
  559.                     nLine = nLine + 1
  560.                     
  561.                 enddo && while nCounter ...
  562.                 
  563.             endif && lToScreen
  564.             
  565.         endif && memlines(bio) > 0
  566.         
  567.         *-------------------------------------------------------------------
  568.         *-- End of MEMO field
  569.         *--------------------------------------------------------------------
  570.         
  571.         *-- blank line between records ...
  572.         ?
  573.        nLine = nLine + 1
  574.  
  575.         skip      && to next record
  576.         if eof()  && jest in case ...
  577.             exit   && we can leave the loop ...
  578.         endif     && eof()
  579.  
  580.     enddo && end of loop
  581.  
  582. *-------------------------------------------------------------------------------
  583. *-- all the rest of this is cleanup ...
  584. *-------------------------------------------------------------------------------
  585. set filter to   && turn off filter if there was one ...
  586. if .not. lToScreen .and. .not. lToFile .and. .not. lEsc
  587.     eject        && get that last sheet out of the printer ...
  588. endif
  589.  
  590. if lToScreen  && sent to screen, get rid of window ...
  591.     if .not. lEsc
  592.         do center with 17,80,"&cStand2","Press any key to continue ..."
  593.         x=inkey(0)   && a final pause ...
  594.     endif
  595.     deactivate window wRep2Scr
  596.     release window wRep2Scr
  597. endif
  598.  
  599. *-- return to the screen
  600. set print off
  601. if .not. lToScreen .and. window() = "WPROGBAR" && user <esc>aped out ...
  602.     deactivate window wProgBar
  603.     release window wProgBar
  604.     release screen sProgBar
  605.     release nFactor,nTimes
  606. endif
  607.  
  608. *-- restore environment
  609. set console on
  610. set cursor on
  611. set device to screen
  612. set printer to
  613. set escape off
  614. on escape
  615. set memowidth to nMemoWidth
  616.  
  617. *-- set printer back
  618. if .not. lToScreen .and. .not. lToFile
  619.     _pDriver  = cPDriver
  620.     _pEject   = cPEject
  621.     _pLength  = nPLength
  622.     _pWait    = lPWait
  623.     on error do nothing    && routine handles pquality problems ... I hope
  624.     _pQuality = lPQuality  && if printer driver doesn't support "quality", we should
  625.                            && drop to error routine below, and deal with it
  626.     on error               && reset processing for "ON ERROR"
  627. endif
  628.  
  629. *-- clean up the screen, close down and release all that stuff
  630. restore screen from sRep
  631. release screen sRep
  632. do ReColor with cRepColor  && restore colors to how they were set before
  633.                            && entering this program ...
  634. close database
  635.  
  636. *-------------------------------------------------------------------------------
  637. *-- back to the menu
  638. *-------------------------------------------------------------------------------
  639. RETURN
  640.  
  641. *-------------------------------------------------------------------------------
  642. *-- End of Main ...
  643. *-------------------------------------------------------------------------------
  644.  
  645. *-------------------------------------------------------------------------------
  646. *-- This is a fairly standard heading routine ...
  647. *-------------------------------------------------------------------------------
  648.  
  649. PROCEDURE Heading
  650.     
  651.     nPage = nPage + 1       && increment page counter
  652.     
  653.     if lToScreen            && if to screen, don't bother with the 'heading' ...
  654.     
  655.         if nPage > 1         && don't do this on first screen
  656.             do center with 17,80,"&cStand2","Press <Esc> to stop, "+;
  657.                 "or any other key to continue ..."
  658.             x = inkey(0)      && pause for user
  659.             *-- this line added by JOEY to allow <Esc> to exit at prompt
  660.             lEsc = iif(lastkey() = 27,.t.,.f.)
  661.             ?                 && to clear out anything in buffer
  662.             nLine = 0         && set line counter to 0
  663.             clear             && window
  664.         endif
  665.         
  666.     else                    && to printer or REPORT.TXT file
  667.     
  668.         if nPage > 1         && don't eject on first page -- waste of paper
  669.            eject
  670.         endif
  671.     
  672.         *-- print heading
  673.         ?? "BOR-BBS Users List" at 31  style "B"
  674.         ?   
  675.         ?? "Printed: "+dtoc(date()) at 31
  676.         ?
  677.         ?? "Page: "+ltrim(str(nPage)) at 35
  678.         ?
  679.         ?  && blank lines
  680.         ?
  681.     
  682.         *-- heading is printed, five lines ...
  683.         nLine = 5
  684.     
  685.     endif  && lToScreen
  686.     
  687.     *-- don't come back again until we're ready (turn off heading)
  688.     lHeading = .f.
  689.  
  690. RETURN
  691. *-- EoP: Heading
  692.  
  693. *-- This heading routine (HEADING2) is here to cope with long memos.
  694. *-- It prints the 'usual' heading, but adds a line mentioning the fact
  695. *-- that someone's BIO is being printed ... Note that since the bio is
  696. *-- not sent to the screen, the section in the heading dealing with 
  697. *-- 'lToScreen' memvar has been removed from this copy of the heading.
  698. PROCEDURE Heading2
  699.     
  700.     nPage = nPage + 1       && increment page counter
  701.     
  702.     if nPage > 1         && don't eject on first page -- waste of paper
  703.           eject
  704.     endif
  705.     
  706.     *-- print heading
  707.     ?? "BOR-BBS Users List" at 31  style "B"
  708.     ?   
  709.     ?? "Printed: "+dtoc(date()) at 31
  710.     ?
  711.     ?? "Page: "+ltrim(str(nPage)) at 35
  712.     ?
  713.     ?  && blank lines
  714.     ?
  715.     
  716.     *-- print note about the fact that we're printing the BIO for
  717.     *-- a user ...
  718.     ?? "BIO for "+trim(first_name)+" "+iif(.not. isblank(mi),mi+". ","")+;
  719.             trim(last_name)+" ("+trim(borbbs_id)+")" at 5 style "B"
  720.     ?
  721.     ? && add a blank line here ...
  722.     nLine = 7
  723.     
  724.     *-- don't come back again until we're ready (turn off heading)
  725.     lHeading = .f.
  726.  
  727. RETURN
  728. *-- EoP: Heading2
  729.  
  730. *-------------------------------------------------------------------------------
  731. *-- This simple procedure is designed to see if there's enough room at 
  732. *-- the bottom of the page for the current record. It does this by 
  733. *-- checking to see what will be printed, and counting the # of lines
  734. *-- that will be printed, added to the current line number, and checking
  735. *-- against the bottom of the page ... (63). If there's not enough room,
  736. *-- we set the memvar lHeading to .t., otherwise to .f..
  737. *--   While this routine slows down the printout, it makes for a cleaner
  738. *--   report. Records that CAN fit at the bottom of a page are printed there,
  739. *--   rather than leaving a large white space. Records that can't get moved
  740. *--   to the next page, even if it DOES mean leaving white space. There's
  741. *--   no splitting of records here ...
  742. *-------------------------------------------------------------------------------
  743.  
  744. PROCEDURE LineCount
  745.  
  746.     nCount = nLine                && grab line counter value ...
  747.     nCount = nCount + 1           && count for "Borland BBS ID:" line
  748.     
  749.     if .not. IsBlank(haddress1)
  750.         nCount = nCount + 2        && "Home Address:" and address itself ...
  751.     endif
  752.     
  753.     if .not. IsBlank(hcity) .or. .not. IsBlank(hPhone)
  754.         nCount = nCount + 1        && either way we print a line ...
  755.     endif
  756.     
  757.     if .not. IsBlank(baddress1) .or. .not. IsBlank(company) .or. ;
  758.         .not. IsBlank(title) .or. .not. IsBlank(bcity) .or. .not. IsBlank(bPhone)
  759.         nCount = nCount + 1
  760.     endif
  761.     
  762.     if .not. IsBlank(company) .or. .not. IsBlank(title)
  763.         nCount = nCount + 1  && either way we print a line
  764.     endif
  765.     
  766.     if .not. IsBlank(baddress1) .or. .not. IsBlank(bAddress2)
  767.         nCount = nCount + 1
  768.     endif
  769.     
  770.     if .not. IsBlank(bcity) .or. .not. IsBlank(bPhone)
  771.         nCount = nCount + 1
  772.     endif
  773.     
  774.     if .not. IsBlank(fax) .or. .not. IsBlank(bbsphone)
  775.         nCount = nCount + 1
  776.     endif
  777.     
  778.     if .not. IsBlank(compuserve) .or. .not. IsBlank(mci_mail) .or.;    
  779.         .not. IsBlank(genie) .or. .not. IsBlank(fido) .or.;
  780.         .not. IsBlank(internet) .or. .not. IsBlank(source) .or.;
  781.         .not. IsBlank(prodigy) .or. .not. IsBlank(delphi) .or.;
  782.         .not. IsBlank(am_online)
  783.         nCount = nCount + 1  && "EMAIL Addresses:" line
  784.     endif
  785.     
  786.     if .not. IsBlank(compuserve) .or. .not. IsBlank(mci_mail)
  787.         nCount = nCount + 1
  788.     endif
  789.     
  790.     if .not. IsBlank(genie) .or. .not. IsBlank(fido)
  791.         nCount = nCount + 1
  792.     endif
  793.     
  794.     if .not. IsBlank(internet)
  795.         nCount = nCount + 1
  796.     endif
  797.     
  798.     if .not. IsBlank(prodigy)
  799.         nCount = nCount + 1
  800.     endif
  801.     
  802.     if .not. IsBlank(Delphi)
  803.         nCount = nCount + 1
  804.     endif
  805.     
  806.     if .not. IsBlank(am_online)
  807.         nCount = nCount + 2
  808.     endif
  809.     
  810.     if .not. IsBlank(source)
  811.         nCount = nCount + 2
  812.     endif
  813.     
  814.     *-- if sending to screen, we're only displaying 1 line of info if there's
  815.     *-- anything in the memo.
  816.     if lToScreen .and. memlines(bio) > 0
  817.         nCount = nCount + 1
  818.     endif
  819.     
  820.     *-- otherwise we have to deal with the section in the report itself
  821.     *-- SHOULD handle the memo ... 
  822.     
  823.     if (nCount => 60 .and. .not. lToScreen) .or. ;
  824.         (nCount => 15 .and. lToScreen)   && absolute bottom of page/screen (-2)
  825.         lHeading = .t.                   && we're turning on the header ...
  826.     else
  827.         lHeading = .f. && there's room ...
  828.     endif
  829.     
  830. RETURN
  831. *-- EoP: LineCount
  832.  
  833. *-------------------------------------------------------------------------------
  834. *-- PRNTCHOOSE is based loosely (heavily modified) on some configuration 
  835. *-- routines I got from BOWEN. The idea is to allow the user to choose from
  836. *-- the configuration they currently have, one of two printers, and setting
  837. *-- things to the screen, or a print file, are options. 
  838. *-------------------------------------------------------------------------------
  839.  
  840. PROCEDURE PrntChoose
  841.  
  842.     *-- save the screen
  843.     save screen to sPrint
  844.     
  845.     *-- get printer memvars
  846.     restore from printer.mem additive  
  847.     cDriver1 = trim(p_driver1)
  848.     cDriver2 = trim(p_driver2)
  849.     
  850.     *-- Initialize a few memvars ...
  851.     lToScreen = .f.
  852.     lToFile = .f.
  853.     _Peject = "NONE"
  854.     _PageNo = 1
  855.     _PLineNo = 0
  856.     cSafety = set("SAFETY")
  857.     
  858.     *-- save current colors
  859.     cPopColor = set("ATTRIBUTES")
  860.     *-- set colors for popups
  861.     set color of message to &cStand2
  862.     set color of highlight to &cStand
  863.     set color of box to &cStand2
  864.     
  865.     *-- define popups  -- this one handles where to send output
  866.     define popup pWhere from 10,33 && to 16,45
  867.     define bar 1 of pWhere prompt " Output To " skip
  868.     define bar 2 of pWhere prompt replicate(chr(196),11) skip
  869.     define bar 3 of pWhere prompt " Screen";
  870.         message "Send output to screen"
  871.     define bar 4 of pWhere prompt " Printer  "+chr(16) ;
  872.         message "Send output to printer"
  873.     define bar 5 of pWhere prompt " File";
  874.         message "Send output to file REPORT.TXT (or one of your choosing)"
  875.     on selection popup pWhere deactivate popup
  876.     
  877.     *-- this popup handles quality mode ...
  878.     define popup pQuality from 10,31 && to 16,50
  879.     define bar 1 of pQuality prompt " Letter or Draft " skip
  880.     define bar 2 of pQuality prompt "   Print Mode "    skip
  881.     define bar 3 of pQuality prompt replicate(chr(196),18) skip
  882.     define bar 4 of pQuality prompt " Letter" ;
  883.         message "Letter Quality mode"
  884.     define bar 5 of pQuality prompt " Draft";
  885.         message "Draft Quality mode"
  886.     on selection popup pQuality deactivate popup
  887.     
  888.     *-- this one handles the printer choice ...
  889.     define popup pPrinter from 10,31 && to 15,48
  890.     define bar 1 of pPrinter prompt " Printer Choice " skip
  891.     define bar 2 of pPrinter prompt replicate(chr(196),16) skip
  892.     define bar 3 of pPrinter prompt " Printer #1" message p_name1
  893.     define bar 4 of pPrinter prompt " Printer #2" message p_name2
  894.     on selection popup pPrinter deactivate popup
  895.     
  896.     *-- start with the 'Where to send it' option ...
  897.     do shadow with 10,33,16,45
  898.     activate popup pWhere
  899.     if lastkey() = 27   && <Esc> key ...
  900.         lEsc = .t.       && just to make sure
  901.         restore screen from sPrint
  902.     endif
  903.     if lEsc
  904.         do ReColor with cPopColor
  905.         return
  906.     endif
  907.     
  908.     *-- determine what's next based on choice from the pWhere menu
  909.     do case
  910.         
  911.         *--------------------------------------------------------------------
  912.         *-- Sending output to the screen ... 
  913.         *--------------------------------------------------------------------
  914.         case bar() = 3  && to the screen
  915.             set cursor off
  916.             restore screen from sPrint
  917.             activate screen
  918.             *-- if this driver does not exist
  919.             if .not. file("ASCII.PR2")
  920.                 *-- GET it ...
  921.                 run drivers.exe -o ASCII.PR2 > nul
  922.             endif
  923.             _Pdriver = "ASCII.PR2"
  924.             _Plength = 17
  925.             nPageLen = 15
  926.             lToScreen = .t.
  927.             *-- do this in a window ... which will be activated in main routine
  928.             define window wRep2Scr from 5,0 to 22,79 color &cStand NONE
  929.         
  930.         *--------------------------------------------------------------------
  931.         *-- Send it to the printer. This is the complex bit. Once we know
  932.         *-- we're sending it to the printer, we need to handle printer
  933.         *-- quality, and which printer driver/printer to send it to.
  934.         *--------------------------------------------------------------------
  935.         case bar() = 4  && to the printer
  936.             *-- deal with setting up the printer ...
  937.             restore screen from sPrint
  938.             do shadow with 10,31,16,50
  939.             
  940.             *-- find out about printer quality
  941.             activate popup pQuality
  942.             if lastkey() = 27
  943.                 restore screen from sPrint
  944.                 lEsc = .t.     && just to make sure
  945.             endif
  946.             if lEsc
  947.                 do ReColor with cPopColor
  948.                 return
  949.             endif
  950.             restore screen from sPrint
  951.             
  952.             *-- printer quality ...
  953.             lPQuality = (bar() = 4)
  954.             do shadow with 10,31,15,48
  955.             
  956.             *-- figure out which printer driver to deal with ...
  957.             activate popup pPrinter
  958.             if lastkey() = 27
  959.                 restore screen from sPrint
  960.                 lEsc = .t.     && just to make sure
  961.             endif
  962.             if lEsc
  963.                 do ReColor with cPopColor
  964.                 RETURN
  965.             endif
  966.             restore screen from sPrint
  967.             if bar() = 3
  968.                 do while .not. printstatus() .and. .not. lEsc
  969.                     do printerr
  970.                 enddo
  971.                 _pdriver=p_driver1
  972.                 set printer to &p_port1  && printer location
  973.             else
  974.                 do while .not. printstatus() .and. .not. lEsc
  975.                     do printerr
  976.                 enddo
  977.                 _pdriver=p_driver2
  978.                 set printer to &p_port2  && printer location
  979.             endif
  980.             *-- if "quality" isn't handled here, drop to ERR_ROUTINE,
  981.             *-- I hope ...
  982.             _PQuality = lPQuality
  983.             _pWait = .f.
  984.         
  985.         *--------------------------------------------------------------------
  986.         *-- Send output to a file. This routine defines the default file as being
  987.         *-- called: REPORT.TXT
  988.         *--------------------------------------------------------------------
  989.         case bar() = 5  && to file
  990.             restore screen from sPrint
  991.             *-- if file REPORT.TXT (or whatever file user wants) exists, erase it
  992.             *-- we're asking for the report file ... now.
  993.             cFile = "REPORT.TXT  "
  994.             do while .t.
  995.                 @15,15 say "Enter name of file: " color &cStand
  996.                 @15,35 get cFile picture "@!";
  997.                     message "Enter name of output file, <Enter> to accept current"
  998.                 read
  999.                 @17,0 fill to 23,79 color &cStand && clear out screen ...
  1000.                 if file("&cFile")
  1001.                     cYN = " "
  1002.                     @17,15 say "File already exists - erase? " color &cStand
  1003.                     @17,44 get cYN picture "!";
  1004.                         valid required cYN $ "YN" error "Enter 'Y' or 'N'"
  1005.                     read
  1006.                     
  1007.                     *-- if yes, erase it ...
  1008.                     if cYN = "Y"
  1009.                         erase (cFile)
  1010.                         exit
  1011.                     endif
  1012.                 
  1013.                 else  && file doesn't exist, which is fine ...
  1014.                     exit
  1015.                 endif  && file("&cFile")
  1016.                 
  1017.             enddo  && while .t.
  1018.             set safety off
  1019.             set printer to file (cFile)
  1020.             *-- if driver ASCII.PR2 doesn't exist, extract it
  1021.             if .not. file("ASCII.PR2")
  1022.                 set console off
  1023.                 run drivers.exe -o ASCII.PR2 > nul
  1024.                 set console on
  1025.             endif
  1026.             _Pdriver = "ASCII.PR2"
  1027.             _Plength = 65
  1028.             _PWait = .f.
  1029.             lToFile = .t.
  1030.             set safety &cSafety
  1031.     endcase
  1032.     
  1033.     *-- cleanup ...
  1034.     restore screen from sPrint
  1035.     release screen sPrint
  1036.     release popup pWhere
  1037.     release popup pPrinter
  1038.     release popup pQuality
  1039.     *-- reset colors
  1040.     do ReColor with cPopColor
  1041.     
  1042. RETURN
  1043. *-- EoP: PrntChoose
  1044.  
  1045. PROCEDURE Err_Routine
  1046.  
  1047.     if error() = 331     && current printer driver does not support quality
  1048.         lPQuality = .f.   && reset, and 
  1049.         RETRY             && reissue command ...
  1050.     endif
  1051.     
  1052.     *-- new errors ... 125 = Printer not ready, 
  1053.     *--                126 = Printer not connected or is turned off
  1054.     if error() = 125 .or. error() = 126
  1055.         do printerr       && procedure in PROC.PRG
  1056.         RETRY
  1057.     endif
  1058.  
  1059. RETURN
  1060. *-- EoP: Err_Routine
  1061.  
  1062. PROCEDURE Nothing   && here at the request of Keith ...
  1063.  
  1064. RETURN
  1065. *-- EoP: Nothing
  1066.  
  1067. *-------------------------------------------------------------------------------
  1068. * EoP: BORREP.PRG
  1069. *-------------------------------------------------------------------------------
  1070.